home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / 24BitChunky / depmacros_ns.i < prev    next >
Encoding:
Text File  |  1996-08-14  |  5.3 KB  |  292 lines

  1.  
  2. ; Useful macros. Last updated 13-Aug-1996
  3.  
  4.  
  5. ;-----------------------------------------------------------------
  6. ; macro : Call
  7. ; \1 : _LVO function
  8. ;-----------------------------------------------------------------
  9.  
  10. Call        MACRO
  11.         jsr    _LVO\1(a6)
  12.         ENDM
  13.  
  14.  
  15.  
  16. ;-----------------------------------------------------------------
  17. ; macro : Callxxx
  18. ; \1 : _LVO function in xxx.library
  19. ;-----------------------------------------------------------------
  20.  
  21. CallExec    MACRO
  22.         LibBase exec
  23.         jsr    _LVO\1(a6)
  24.         ENDM
  25.  
  26. CallDos        MACRO
  27.         LibBase dos
  28.         jsr    _LVO\1(a6)
  29.         ENDM
  30.  
  31. CallInt        MACRO
  32.         LibBase intuition
  33.         jsr    _LVO\1(a6)
  34.         ENDM
  35.  
  36. CallGfx        MACRO
  37.         LibBase graphics
  38.         jsr    _LVO\1(a6)
  39.         ENDM
  40.  
  41. CallCyb        MACRO
  42.         LibBase cybergraphics
  43.         jsr    _LVO\1(a6)
  44.         ENDM
  45.  
  46.  
  47.  
  48.  
  49.  
  50. ;-----------------------------------------------------------------
  51. ; macro: Print
  52. ; \1 : <string>
  53. ;-----------------------------------------------------------------
  54.  
  55. Print        MACRO
  56.         LibBase    dos
  57.         move.l    #.ps\@,d1
  58.         Call    PutStr
  59.         bra    .ha\@
  60. .ps\@        dc.b    "\1",10,0
  61.         even
  62. .ha\@        
  63.         ENDM
  64.  
  65. ;-----------------------------------------------------------------
  66. ; macro: PrintS
  67. ; \1 : string label
  68. ;-----------------------------------------------------------------
  69.  
  70. PrintS        MACRO
  71.         LibBase    dos
  72.         move.l    #\1,d1
  73.         Call    PutStr
  74.         ENDM
  75.  
  76. ;-----------------------------------------------------------------
  77. ; macro: PrintF
  78. ; \1 : string label, assume data is in <label>dt
  79. ;-----------------------------------------------------------------
  80.  
  81. PrintF        MACRO
  82.         movem.l    d0-d7/a0-a3,-(sp)
  83.         lea.l    \1,a0
  84.         lea.l    \1dt,a1
  85.         lea.l    __TempString,a3
  86.         lea.l    __StackChar,a2
  87.         move.l    $4.w,a6
  88.         JSRLIB    RawDoFmt
  89.         PrintS    __TempString
  90.         movem.l    (sp)+,d0-d7/a0-a3
  91.         ENDM
  92.  
  93. __StackChar    move.b    d0,(a3)+
  94.         rts
  95.  
  96. __TempString    ds.b    1024
  97.  
  98. ;-------------------------------------------------------------------
  99.  
  100.  
  101.  
  102.  
  103.  
  104. ;-----------------------------------------------------------------
  105. ; macro: Save
  106. ; \1 : <filename>
  107. ; \2 : <address>
  108. ; \3 : <lenght>
  109. ;-----------------------------------------------------------------
  110.  
  111. Save        MACRO
  112.         LibBase    dos
  113.         move.l    #name\@,d1
  114.         move.l    #MODE_NEWFILE,d2
  115.         jsr    _LVOOpen(a6)
  116.         tst.l    d0
  117.         beq    err\@
  118.  
  119.         move.l    d0,handle\@
  120.         move.l    d0,d1
  121.         move.l    #\2,d2
  122.         move.l    #\3,d3
  123.         jsr    _LVOWrite(a6)
  124.  
  125.         move.l    handle\@,d1
  126.         jsr    _LVOClose(a6)
  127.         bra    err\@
  128.  
  129. name\@        dc.b    "\1",0
  130.         even
  131. handle\@    dc.l    0
  132.  
  133. err\@
  134.         ENDM
  135.  
  136.  
  137.  
  138.  
  139.  
  140. ;-----------------------------------------------------------------
  141. ; macro: SetCopBpl
  142. ;
  143. ; \1 : label holding address of first bitplane
  144. ; \2 : bitplane size
  145. ; \3 : number of bitplanes
  146. ; \4 : copper address (bitplane #0) 
  147. ;-----------------------------------------------------------------
  148.  
  149. SetCopBpl    MACRO
  150.         move.l    \1,d0
  151.         lea.l    \4,a0
  152.         move.w    #\3-1,d7
  153. .l\@        move.w    d0,6(a0)
  154.         swap    d0
  155.         move.w    d0,2(a0)
  156.         swap    d0
  157.         add.l    #\2,d0
  158.         addq.l    #8,a0
  159.         dbf    d7,.l\@
  160.         ENDM
  161.  
  162.  
  163.  
  164.  
  165.  
  166. ;-----------------------------------------------------------------
  167. ; macro: SetCopper
  168. ;
  169. ; \1 : Copperlist to load
  170. ;-----------------------------------------------------------------
  171.  
  172. SetCopper    MACRO
  173.         move.l    #\1,$dff080
  174.         clr.w    $dff088
  175.         ENDM
  176.  
  177.  
  178.  
  179.  
  180. ;-----------------------------------------------------------------
  181. ; usage of storage macros LoadData and FreeData:
  182. ;
  183. ; Load your stuff with LoadData, specify MEMF_CHIP or MEMF_FAST
  184. ; You can now access the data from the address stored at <nickname>
  185. ; When the data is not needed anymore, do a FreeData <nickname>
  186. ;-----------------------------------------------------------------
  187.  
  188.  
  189. ;-----------------------------------------------------------------
  190. ; macro: FreeData
  191. ; \1 : <nickname>
  192. ;-----------------------------------------------------------------
  193.  
  194. FreeData    MACRO
  195.         tst.l    \1
  196.         beq.s    .e\@
  197.         move.l    $4.w,a6
  198.         move.l    \1,a1
  199.         move.l    \1+4,d0
  200.         Call    FreeMem
  201.         clr.l    \1    ; if you FreeData once more
  202. .e\@
  203.         ENDM
  204.  
  205. ;-----------------------------------------------------------------
  206. ; macro: LoadData -> d0 (0=fail)
  207. ;
  208. ; \1 : <filename>
  209. ; \2 : MEMF_CHIP or MEMF_FAST
  210. ; \3 : <nickname> for use with FreeData later on
  211. ;-----------------------------------------------------------------
  212.  
  213. LoadData    MACRO
  214.         LibBase dos
  215.         move.l    #.name,d1        ; name
  216.         move.l    #ACCESS_READ,d2        ; mode of file
  217.         Call    Lock            ; lock file
  218.         beq    .quit            ; quit!
  219.         move.l    d0,.lock        ; save lock
  220.  
  221.         move.l    d0,d1
  222.         Call    OpenFromLock
  223.         beq    .quit
  224.         move.l    d0,.file
  225.  
  226.         move.l    .lock,d1
  227.         move.l    #.fib,d2
  228.         Call    Examine
  229.         beq    .quit
  230.  
  231.         move.l    $4.w,a6
  232.         move.l    .fib+fib_Size,d0
  233.         move.l    #\2,d1            ; MEMF_CHIP or MEMF_FAST
  234.         Call    AllocMem
  235.         beq    .quit
  236.         move.l    d0,.return
  237.  
  238.         LibBase    dos
  239.         move.l    .file,d1
  240.         move.l    d0,d2
  241.         move.l    .fib+fib_Size,d3
  242.         Call    Read
  243.         bra    .quit
  244.  
  245. .return        dc.l    0
  246. .file        dc.l    0
  247. .lock        dc.l    0
  248. .name        dc.b    "\1",0
  249.         cnop    0,4
  250. .fib        ds.b    fib_SIZEOF
  251.  
  252. .quit        LibBase    dos
  253.         move.l    .file,d1
  254.         beq.s    .nof
  255.         Call    Close
  256. .nof
  257.         move.l    .lock,d1
  258.         beq.s    .nol
  259.         Call    UnLock
  260.  
  261. .nol        move.l    .return,d0
  262.         move.l    .fib+fib_Size,\3+4
  263.         move.l    d0,\3
  264.         bra.s    mdone\@
  265. \3        dc.l    0,0
  266. mdone\@
  267.         ENDM
  268.  
  269.  
  270.  
  271. ;-----------------------------------------------------------------
  272. ; macro: SetDMA
  273. ; \1 : DMA bits
  274. ;-----------------------------------------------------------------
  275.  
  276. SetDMA:        MACRO
  277.         move.w    #DMAF_SETCLR!\1,$dff096
  278.         ENDM
  279.  
  280. ;-----------------------------------------------------------------
  281. ; macro: ClrDMA
  282. ; \1 : DMA bits or "ALL"
  283. ;-----------------------------------------------------------------
  284.  
  285. ClrDMA:        MACRO
  286.         IFC    "\1","ALL"
  287.             move.w    #$3FFF,$dff096
  288.         ELSE
  289.         move.w    #\1,$dff096
  290.         ENDC    
  291.         ENDM
  292.